<?xml version="1.0" encoding="utf-8"?>
<!--
	Copyright (C) 2010 Ethan Gruber
	EADitor: http://code.google.com/p/eaditor/
	Apache License 2.0: http://code.google.com/p/eaditor/    
-->
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events"
	xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ead="urn:isbn:1-931666-22-9"
	xmlns="urn:isbn:1-931666-22-9" xmlns:eaditor="http://code.google.com/p/eaditor/" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
	<xhtml:head>
		<xhtml:title>EADitor: Edit Component Template</xhtml:title>
		<xhtml:link rel="stylesheet" type="text/css" href="/apps/eaditor/css/grids-min.css"/>
		<xhtml:link rel="stylesheet" type="text/css" href="/apps/eaditor/css/reset-fonts-grids.css"/>
		<xhtml:link rel="stylesheet" type="text/css" href="/apps/eaditor/css/base-min.css"/>
		<xhtml:link rel="stylesheet" type="text/css" href="/apps/eaditor/css/fonts-min.css"/>
		<!-- EADitor styling -->
		<xhtml:link rel="stylesheet" href="/apps/eaditor/css/style.css"/>
		<xhtml:link rel="stylesheet" href="/apps/eaditor/css/themes/smoothness.css"/>
		
		<xhtml:script type="text/javascript" src="/apps/eaditor/javascript/jquery-1.4.2.min.js"/>
		<xhtml:script type="text/javascript" src="/apps/eaditor/javascript/menu.js"/>
		<xforms:model>
			<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified">
				<xs:simpleType name="iso8601date">
					<xs:restriction base="xs:string">
						<xs:pattern
							value="(\-?(0|1|2)([0-9]{3})(((01|02|03|04|05|06|07|08|09|10|11|12)((0[1-9])|((1|2)[0-9])|(3[0-1])))|\-((01|02|03|04|05|06|07|08|09|10|11|12)(\-((0[1-9])|((1|2)[0-9])|(3[0-1])))?))?)(/\-?(0|1|2)([0-9]{3})(((01|02|03|04|05|06|07|08|09|10|11|12)((0[1-9])|((1|2)[0-9])|(3[0-1])))|\-((01|02|03|04|05|06|07|08|09|10|11|12)(\-((0[1-9])|((1|2)[0-9])|(3[0-1])))?))?)?"
						/>
					</xs:restriction>
				</xs:simpleType>
			</xs:schema>
			
			<!-- exist URL is stored in an XML file -->
			<xforms:instance id="exist-url">
				<xi:include href="exist-url.xml"/>
			</xforms:instance>
			
			<!-- archdesc instances -->
			<xforms:instance id="c-template">
				<c xmlns="urn:isbn:1-931666-22-9"/>
			</xforms:instance>

			<xforms:instance id="status">
				<status/>
			</xforms:instance>

			<xforms:instance id="identifier">
				<id xmlns=""/>
			</xforms:instance>

			<!-- controlled instances -->
			<!-- component level -->
			<xforms:instance id="level-template">
				<levels xmlns="">
					<level value="">Select...</level>
					<level value="class">Class</level>
					<level value="collection">Collection</level>
					<level value="file">File</level>
					<level value="fonds">Fonds</level>
					<level value="item">Item</level>
					<level value="recordgrp">Record Group</level>
					<level value="series">Series</level>
					<level value="subfonds">Subfonds</level>
					<level value="subgrp">Subgroup</level>
					<level value="subseries">Subseries</level>
					<level value="otherlevel">Other Level</level>
				</levels>
			</xforms:instance>

			<xforms:bind node="instance('c-template')">
				<xforms:bind nodeset="ead:archdesc">
					<xforms:bind nodeset="//ead:defitem">
						<xforms:bind nodeset="ead:label" required="true()"/>
						<xforms:bind nodeset="ead:item" required="true()"/>
					</xforms:bind>
				</xforms:bind>
				<xforms:bind nodeset="//ead:tgroup/@cols" required="true()" type="xs:integer"/>
				<xforms:bind nodeset="//ead:listhead">
					<xforms:bind nodeset="ead:head01" required="true()"/>
					<xforms:bind nodeset="ead:head02" required="true()"/>
				</xforms:bind>
				<xforms:bind nodeset="//ead:ref" required="true()"/>
				<xforms:bind nodeset="//ead:extref" required="true()">
					<xforms:bind nodeset="@href" required="true()"/>
				</xforms:bind>
				<xforms:bind nodeset="//ead:dao/@href" required="true()"/>
				<xforms:bind nodeset="//ead:daoloc/@href" required="true()"/>				
				<xforms:bind nodeset="//ead:unitdate/@normal" type="xs:date"/>
				<xforms:bind nodeset="//ead:date/@normal" type="xs:date"/>				
			</xforms:bind>
			
			<!-- load preliminary instances -->			
			<xforms:submission id="load-c-template" serialization="none" method="get" action="{instance('exist-url')}eaditor/c-template.xml" replace="instance" instance="c-template"
				xxforms:username="admin" xxforms:password=""/>	

			<!-- Submission to get the document -->
			<xforms:submission id="load-submission" serialization="none" method="get" action="{instance('exist-url')}eaditor/c-template.xml" replace="instance" instance="c-template" xxforms:username="admin" xxforms:password=""/>

			<!-- Submission to save the document -->
			<xforms:submission id="save-submission" ref="instance('c-template')" action="{instance('exist-url')}eaditor/c-template.xml" method="put" replace="none" xxforms:username="admin" xxforms:password="">
				<xforms:message ev:event="xforms-submit-error" level="modal">An error occurred while saving!</xforms:message>
				<xforms:setvalue ev:event="xforms-submit-done" ref="instance('status')">Template saved.</xforms:setvalue>
			</xforms:submission>

			<!-- ************************ xforms-model-construct-done ****************************** -->
			<xforms:action ev:event="xforms-model-construct-done">
				<xforms:send submission="load-submission"/>				
				<xforms:send submission="load-c-template"/>				
			</xforms:action>
		</xforms:model>

		<!-- xbl components -->
		<xi:include href="oxf:/xbl/eaditor/access-elements/access-elements.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/accessrestrict/accessrestrict.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/accruals/accruals.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/acqinfo/acqinfo.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/address/address.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/altformavail/altformavail.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/appraisal/appraisal.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/arrangement/arrangement.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/attributes/attributes.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/author/author.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/bibliography/bibliography.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/bibref/bibref.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/bioghist/bioghist.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/blockquote/blockquote.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/c/c.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/chronlist/chronlist.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/component-level/component-level.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/controlaccess/controlaccess.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/corpname/corpname.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/creation/creation.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/custodhist/custodhist.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/dao/dao.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/daodesc/daodesc.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/daogrp/daogrp.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/daoloc/daoloc.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/date/date.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/did/did.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/descgrp/descgrp.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/extptrloc/extptrloc.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/extref/extref.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/extrefloc/extrefloc.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/famname/famname.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/fileplan/fileplan.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/function/function.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/generic-elements/generic-elements.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/genreform/genreform.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/geogname/geogname.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/head/head.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/index/index.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/linkgrp/linkgrp.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/list/list.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/listhead/listhead.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/name/name.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/namegrp/namegrp.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/note/note.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/num/num.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/occupation/occupation.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/odd/odd.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/originalsloc/originalsloc.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/otherfindaid/otherfindaid.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/p/p.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/persname/persname.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/phystech/phystech.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/prefercite/prefercite.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/processinfo/processinfo.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/ptr/ptr.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/ptrgrp/ptrgrp.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/ptrloc/ptrloc.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/publisher/publisher.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/ref/ref.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/refloc/refloc.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/relatedmaterial/relatedmaterial.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/scopecontent/scopecontent.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/separatedmaterial/separatedmaterial.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/sponsor/sponsor.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/subject/subject.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/subtitle/subtitle.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/table/table.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/title/title.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/titleproper/titleproper.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/unitdate/unitdate.xbl" xxi:omit-xml-base="true"/>
		<xi:include href="oxf:/xbl/eaditor/userestrict/userestrict.xbl" xxi:omit-xml-base="true"/>
	</xhtml:head>
	<xhtml:body class="yui-skin-sam">
		<xhtml:div id="doc4" class="yui-t2">
			<!-- header -->
			<xxforms:variable name="display_path">../../../</xxforms:variable><xi:include href="header-admin.xml"/>

			<xhtml:div id="bd">
				<xhtml:div id="form">
					<xforms:group ref="instance('status')/text()">
						<xhtml:div class="success">
							<xforms:output ref="instance('status')"/>
						</xhtml:div>
					</xforms:group>
					<p>
						<a href="../../templates/">&lt; Return</a>
					</p>
					<!-- This table contains the main actions for the page  -->
					<xhtml:div class="submission">
						<xforms:submit submission="save-submission" appearance="minimal">
							<xforms:label><xhtml:img src="/apps/eaditor/images/save.gif" alt="Save"/> Save</xforms:label>
						</xforms:submit>
						<xforms:submit submission="load-submission" appearance="minimal">
							<xforms:label><xhtml:img src="/apps/eaditor/images/recycle-green.png" alt="Revert"/>Load</xforms:label>
						</xforms:submit>
					</xhtml:div>
					<xforms:group ref="instance('c-template')">
						<widget:tabs>
							<!--**************************************** DESCRIPTIVE INFORMATION - DID **********************************-->
							<widget:tab id="did">
								<widget:label>Descriptive Identification</widget:label>
								<!-- did-level instances -->
								<xhtml:div class="section">
									<xforms:group ref="ead:did">
										<eaditor:did/>
									</xforms:group>
								</xhtml:div>
							</widget:tab>
							<!--**************************************** END DESCRIPTIVE INFORMATION - DID **********************************-->
							<!--**************************************** COMPONENT-LEVEL INFORMATION **********************************-->
							<widget:tab id="c-level">
								<widget:label>C-level Information</widget:label>
								<!-- include component-level information.  this is broken into a separate XML file so that it can be used in the top-level ead form -->
								<xhtml:div class="section">
									<eaditor:component-level/>
								</xhtml:div>
							</widget:tab>
							<!--**************************************** END COMPONENT-LEVEL INFORMATION **********************************-->
							<!--**************************************** SUB COMPONENTS **********************************-->
							<widget:tab id="subcomponents">
								<widget:label>Subcomponents</widget:label>
								<xhtml:h1>Subcomponents</xhtml:h1>
								<xhtml:div>
									<xforms:trigger appearance="minimal">
										<xforms:label>
											<xhtml:img src="/apps/eaditor/images/add.gif"/>Subcomponent</xforms:label>
										<xforms:insert ev:event="DOMActivate" context="." nodeset="./child::node()[last()]" origin="instance('c-template')"/>
										<xforms:action ev:event="DOMActivate">
											<xforms:setvalue ref="ead:c[last()]/@id" value="concat('c_', string(digest( string( random( true ) ), 'MD5', 'hex' )))"/>
										</xforms:action>
									</xforms:trigger>
								</xhtml:div>
								<xhtml:div class="section">
									<xforms:repeat nodeset="ead:c">
										<eaditor:c/>
									</xforms:repeat>
								</xhtml:div>
							</widget:tab>
						</widget:tabs>
					</xforms:group>
				</xhtml:div>
			</xhtml:div>

			<!-- footer -->
			<xi:include href="xslt/footer.xml"/>
		</xhtml:div>
	</xhtml:body>
</xhtml:html>
